﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataFrameworkAccess.Entity;
using System.Data;
using Xinkui.Common.Enum;

namespace Xinkui.Common
{
    public class FileEntity
    {
        [DataMapping("ID", DbType.Int32)]
        public int FileID
        { get; set; }

        /// <summary>
        /// 附件类别
        /// </summary>
        [DataMapping("SourceType", DbType.Int32)]
        public ESourceType SourceType { get; set; }

        /// <summary>
        /// 附件指定ID
        /// </summary>
        [DataMapping("SourceID", DbType.Int32)]
        public int SourceID { get; set; }

        /// <summary>
        /// 上传用户
        /// </summary>
        [DataMapping("UserID", DbType.Int32)]
        public int UserID { get; set; }

        /// <summary>
        /// 文件名
        /// </summary>
        [DataMapping("FileName", DbType.String)]
        public string FileName { get; set; }

        /// <summary>
        /// 文件扩展名
        /// </summary>
        [DataMapping("FileExtension", DbType.String)]
        public string FileExtension { get; set; }

        /// <summary>
        /// 文件大小
        /// </summary>
        [DataMapping("FileSize", DbType.Int32)]
        public int FileSize { get; set; }

        /// <summary>
        /// 服务端文件名
        /// </summary>
        [DataMapping("FilePath", DbType.String)]
        public string FilePath { get; set; }

        /// <summary>
        /// 上传时间
        /// </summary>
        [DataMapping("CreateDate", DbType.DateTime)]
        public DateTime UpdateDate { get; set; }

        /// <summary>
        /// 服务端完整路径
        /// </summary>
        [DataMapping("ServerPath", DbType.String)]
        public string ServerPath { get; set; }

        /// <summary>
        /// 返回表中保存路径
        /// </summary>
        public string SavePath
        {
            get
            {
                return this.FileID + this.FileExtension.ToLower();
            }

            set { }
        }

        public string ImageUrl
        {
            get
            {
                return FileBase.GetDirectoryPath(this.FileID + this.FileExtension.ToLower(), this.SourceType);
            }
            set
            {

            }
        }
    }
}
